package com.shop.controller;

import com.github.pagehelper.PageInfo;
import com.shop.base.BaseController;
import com.shop.entity.Brand;
import com.shop.service.BrandService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/brand")
public class BrandController extends BaseController {
    private final BrandService brandService;
    @GetMapping("/listBrand")
    public PageInfo<Brand> listBrand(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
        return brandService.listBrand(pageNum, pageSize);
    }
    @GetMapping("/getBrand")
    public Brand getBrand(@RequestParam("name") String name) {
        return brandService.getBrand(name);
    }
    @GetMapping("/getBrandById")
    public Brand getBrandById(@RequestParam("id") Integer id) {
        return brandService.getBrandById(id);
    }
    @GetMapping("/addBrand")
    public void addBrand(@RequestParam("brand") Brand brand) {
        brandService.addBrand(brand);
    }
    @GetMapping("/deleteBrand")
    public void deleteBrand(@RequestParam("id") Integer id) {
        brandService.deleteBrand(id);
    }
    @GetMapping("/updateBrand")
    public void updateBrand(@RequestParam("brand") Brand brand) {
        brandService.updateBrand(brand);
    }
    @GetMapping("/getTotal")
    public int getTotal() {
        return brandService.getTotal();
    }
}
